<?php
/**
* Domain header
*
* $Id: update.php 38 2005-04-03 06:02:47Z vluther $ 				
* @package user_interface
* @version $Rev: 38 $
* @copyright Copyright &copy; 2000-2007, Linuxpowered, Inc               
* @author Vidyut Luther <vid@linuxpowered.com> 
**/

require_once('./global.inc.php') ; 
require_once(INCLUDE_PATH."/Records.class.php") ; 

$dns = new DNSRecord();

$rtypes = $_POST['rtype']; 
$rid = $_POST['rid']; 
$priority = $_POST['priority']; 
$hostname = $_POST['hostname']; 
$ip = $_POST['hostip']; 


/* 
 Do some error checking. Like Valid IP Range, etc 
*/

/* see what type of record this is. */
		switch($rtypes) {
			case MX:
				#echo "$hostname is a MX Record <BR>"; 
				if(empty($priority)) {
					$priority = "200"; 
				}
				
        	
	  		$dns->setMXRecord($ip);
				        
				$dns->mSetId($rid); 
				#$dns->mSetIp($ip); 
				$dns->mSetHostName($hostname);
				$dns->mSetPriority($priority);
				$dns->mSetType($rtypes);
				break;
			case NS:
		#		echo "$hostname is a NS record <BR>"; 
				$priority = ""; 
				$ipaddress = ""; 
				$dns->mSetId($rid); 
				$dns->mSetIp($ip); 
				$dns->mSetHostName($hostname);
				$dns->mSetPriority($priority);
				$dns->mSetType($rtypes);
				break;
			case CNAME:
      	#echo "$hostname is a CNAME record <BR>"; 
				$priority = ""; 
				$type = "CNAME"; 
        $dns->mSetId($rid); 
				$dns->mSetIp($ip,$type); 
				$dns->mSetHostName($hostname);
				$dns->mSetPriority($priority);
				$dns->mSetType($rtypes);
        break ; 
      default: 
				#echo "Updating an $rtypes Type Record <BR>"; 
				$dns->mSetId($rid); 
				$dns->mSetIp($ip); 
				$dns->mSetHostName($hostname);
				$dns->mSetPriority($priority);
				$dns->mSetType($rtypes);
				break;
		}
		#echo "Updating $hostname with an IP address of $ip  "; 			
    $dns->mUpdate(); 
		$dns->mInsert();
		/* 
    echo "....Successful <BR> <center> </center> 
          <form name=\"updateForm\" action=\"manage.php\" method=\"post\">";  echo "<input type=\"hidden\" name=\"mydomains\" value=\"$wdom\">
          <a href=\"javascript:document.updateForm.submit();\">Submit</a> </form> 

    
    "; */
		
header("Location: manage.php"); 


?>
